package com.cpsoft.androiddemo.butterknife;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

import com.cpsoft.androiddemo.R;

import butterknife.Bind;
import butterknife.BindString;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class ButterKnifeActivity extends AppCompatActivity {

    @Bind(R.id.textview)
    TextView mTextView;
    @Bind(R.id.button)
    Button mButton;
    @BindString(R.string.app_name)
    String bindString;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_butterknife);
        ButterKnife.bind(this);//绑定
        mTextView.setText("这样就可以直接使用该TextView\n"+bindString);//这样就可以直接使用该TextView
    }

    @OnClick(R.id.button)//绑定点击事件
    public void onButterKnifeBtnClick(View view) {
        Toast.makeText(ButterKnifeActivity.this,"onButterKnifeBtnClick",Toast.LENGTH_SHORT).show();
    }
}
